package com.lzx.answer.controller.web;

import com.lzx.answer.entity.Reply;
import com.lzx.answer.entity.vo.NicknameVO;
import com.lzx.answer.entity.vo.OssVO;
import com.lzx.answer.service.ReplyService;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/answer/reply/web")
public class WebReplyController {
    @Resource
    private ReplyService replyService;

    //修改用户昵称(问题一级回复)
    @PutMapping("/updateNicknameToReply")
    public String updateNicknameToReply(@RequestBody NicknameVO nicknameVO) {
        return replyService.updateNicknameToReply(nicknameVO);
    }

    //修改用户头像(问题一级回复)
    @PutMapping("/updateAvatarToReply")
    public String updateAvatarToReply(@RequestBody OssVO ossVO) {
        return replyService.updateAvatarToReply(ossVO);
    }

    //热评
    @GetMapping("/hopReply")
    public R hopReply() {
        return replyService.hopReply();
    }

    //问题回复置顶
    @PutMapping("/replyTop/{problemId}/{replyId}")
    public R replyTop(@PathVariable Long problemId, @PathVariable Long replyId) {
        return replyService.replyTop(problemId, replyId);
    }

    //获取当前问题的一级评论
    @GetMapping("/getLevel1Comments/{problemId}")
    public R getLevel1Comments(@PathVariable Long problemId) {
        return replyService.getLevel1Comments(problemId);
    }

    //问题的回复
    @PostMapping("/reply")
    public R reply(@RequestBody Reply reply) {
        return replyService.reply(reply);
    }
}
